package com.woo;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;

public class GdxAppUI2 implements ApplicationListener {

	private Sprite sprite; 
    private SpriteBatch batch; 
	Stage stage; 
	Image background;
	
    @Override 
    public void create() { 
        stage=new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); 
        TextureAtlas atlas=new TextureAtlas(Gdx.files.internal("drawable-mdpi/pack")); //根据pack文件获取所有图片 
        Image image1=new Image(atlas.findRegion("dawangbig")); //获取名为dawang_big的图片，并创建一个Image对象 
       // image1.scaleX=image1.scaleY=0.2f; 
        image1.x=image1.y=0; 
        Image image2=new Image(atlas.findRegion("pokemarkbig1")); 
        image2.x=image2.y=40; 
        //image2.scaleX=image2.scaleY=0.5f; 
        background=new Image(atlas.findRegion("vbg2"));
        batch = new SpriteBatch();
        background.x=background.y=0;
        stage.addActor(background); 
        stage.addActor(image1); 
        stage.addActor(image2); 
        //stage.findActor(sprite);
        sprite=new Sprite(atlas.findRegion("dawangbig"), 80, 80, 400, 300); 
        sprite.setPosition(10, 10); //位置 
        sprite.setRotation(15); //旋转 

    }

    @Override 
    public void dispose() { 
        stage.dispose(); 
    }

    @Override 
    public void pause() { 
        // TODO Auto-generated method stub

    }

    @Override 
    public void render() { 
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); 
        //stage.act(Gdx.graphics.getDeltaTime()); 
        //stage.draw(); 
        batch.begin();
        background.draw(batch, 1);
        sprite.draw(batch);
        batch.end();     
    }

    @Override 
    public void resize(int width, int height) { 
        // TODO Auto-generated method stub

    }

    @Override 
    public void resume() { 
        // TODO Auto-generated method stub

    }

} 
 